{{extend './extend.art'}}
{{block 'title'}}
首页
{{/block}}
{{block 'css'}}
<link rel = "stylesheet" href = "/home/css/index.css">
{{/block}}
{{block 'body'}}
<body>
    {{include './header.art'}}
    <!-- 文章列表开始 -->
    <ul class = "list w1100">
        {{each result.records}}
        <!-- 通过判断索引的值 来决定class类 -->
        <li class = "{{$index%2===0?'fl':'fr'}}">
            <a href = "/home/article?id={{@$value._id}}" class = "thumbnail">
                <img src = "{{$value.cover}}">
            </a>
            <div class = "content">
                <a class = "article-title" href = "/home/article?id={{@$value._id}}">{{$value.title}}</a>
                <div class = "article-info">
                    <span class = "author">{{$value.writer.name}}</span>
                    <span>{{dateFormat($value.time,'yyyy-mm-dd')}}</span>
                </div>
                <div class = "brief">
                    <!--
                        /<[^>]+>/g 这个正则表达式表示的是全局匹配 <> [^>]+表示<>中间的内容 内容中间不能有 >  ^>就是排除> +表示一次或多次 表示中间的
                        内容出现了一次或多次   >表示匹配>符号    substr截取150个字符，最多显示150个字符，就不会出现内容太多撑开盒子  最后面加上...
                        这个@是为了让 &nbsp 等字符正常显示而不是直接显示 &nbsp
                     -->
                    {{@$value.content.replace(/<[^>]+>/g,'').substr(0,150)+'...'}}
                </div>
            </div>
        </li>
        {{/each}}
    </ul>
    <!-- 文章列表结束 -->

    <!-- 分页开始 -->
    <div class = "page w1100">
        <a href = "/home/index?page={{result.page-1}}" style = "display:{{result.page<=1?'none':'inline'}}">上一页</a>
        {{each result.display}}
        <a href = "/home/index?page={{$value}}" class = "{{result.page==$value?'active':''}}">
            {{$value}}
        </a>
        {{/each}}
        <a href = "/home/index?page={{result.page+1}}" style = "display:{{result.page>=result.pages?'none':'inline'}}">下一页</a>
    </div>
    <!-- 分页结束 -->
</body>
{{/block}}